Elide (_x) in the middle of the string, too. (#323956, Abel Cheung)
authorMatthias Clasen <mclasen@redhat.com>
Mon, 8 May 2006 18:10:23 +0000 (18:10 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 8 May 2006 18:10:23 +0000 (18:10 +0000)
2006-05-08  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtktoolbar.c (_gtk_toolbar_elide_underscores): Elide (_x) in the middle
of the string, too.  (#323956, Abel Cheung)

ChangeLog
ChangeLog.pre-2-10
gtk/gtktoolbar.c

index c4680a469f1de6c619c6fb8d54eb4f5349e2d410..68482c1057dbb3f1bc887bc12f454b6f5f13d528 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2006-05-08  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtktoolbar.c (_gtk_toolbar_elide_underscores): Elide (_x) in the middle
+       of the string, too.  (#323956, Abel Cheung)
+
        * gtk/gtkuimanager.c (update_node): Fix tooltips.
 
        * configure.in: Require Pango 1.13.0
index c4680a469f1de6c619c6fb8d54eb4f5349e2d410..68482c1057dbb3f1bc887bc12f454b6f5f13d528 100644 (file)
@@ -1,5 +1,8 @@
 2006-05-08  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtktoolbar.c (_gtk_toolbar_elide_underscores): Elide (_x) in the middle
+       of the string, too.  (#323956, Abel Cheung)
+
        * gtk/gtkuimanager.c (update_node): Fix tooltips.
 
        * configure.in: Require Pango 1.13.0
index 98535add887ca3474304dfc4f1459578a7d2cf81..8aa4e5970d3b32662704e09ba65821bcfe749090 100644 (file)
@@ -4877,38 +4877,40 @@ gchar *
 _gtk_toolbar_elide_underscores (const gchar *original)
 {
   gchar *q, *result;
-  const gchar *p;
+  const gchar *p, *end;
+  gsize len;
   gboolean last_underscore;
-  gint s;
   
   if (!original)
     return NULL;
 
-  s = strlen (original);
-  q = result = g_malloc (s + 1);
+  len = strlen (original);
+  q = result = g_malloc (len + 1);
   last_underscore = FALSE;
   
-  for (p = original; *p; p++)
+  end = original + len;
+  for (p = original; p < end; p++)
     {
       if (!last_underscore && *p == '_')
        last_underscore = TRUE;
       else
        {
          last_underscore = FALSE;
-         *q++ = *p;
+         if (*p != '_' && original + 2 <= p && p + 1 <= end && p[-2] == '(' && p[1] == ')')
+           {
+             q--;
+             *q = '\0';
+             p++;
+           }
+         else
+           *q++ = *p;
        }
     }
 
+  if (last_underscore)
+    *q++ = '_';
+  
   *q = '\0';
-
-  if (s > 4)
-    {
-      if (original[s - 4] == '(' && 
-         original[s - 3] == '_' && 
-         original[s - 1] == ')')
-       q[-3] = '\0';
-    }
-
   
   return result;
 }